﻿@model TagsViewModel

@{ this.Layout = "~/Views/Shared/Layout.cshtml"; }

@this.Html.RenderMessage()

<div class="sitePath">
	<a title="@this.Model.PageDescription" href="@this.Url.Action("Edit")">@this.Model.PageName</a>
</div>

<div class="tagsEditor">
	<h1>@Resources.AddNewTag</h1>
		<span class="nameColumn">
			@Resources.Name
		</span>
		<span class="codeColumn">
			@Resources.Code
		</span>
	<div class="tagsEditorRow">
		@using (this.Html.BeginForm("Edit", "Tags"))
		{ 
			<input type="hidden" name="tagid" value="0" />
			<input type="text" maxlength="@Tag.MaxNameLength" name="name" class="nameColumn @(this.Model.NewTag.IsNameValid ? "" : "errorInput")" value="@this.Model.NewTag.Name" />
			<input type="text" maxlength="@Tag.MaxCodeLength" name="code" class="codeColumn @(this.Model.NewTag.IsCodeValid ? "" : "errorInput")" value="@this.Model.NewTag.Code" />
			<button class="linkButton" value="Save" name="action" title="@Resources.SaveTag" >@Resources.Save</button>
		}
	</div>
</div>

<div class="tagsEditor">
	<h1>@Resources.ExistingTags</h1>
	@foreach (TagViewModel tagModel in this.Model.Tags)
	{ 
		<div class="tagsEditorRow">
	  	@using (this.Html.BeginForm("Edit", "Tags"))
		{ 
			<input type="hidden" name="tagid" value="@tagModel.Id" />
			<input type="text" maxlength="@Tag.MaxNameLength" name="name" class="nameColumn @(tagModel.IsNameValid ? "" : "errorInput")" value="@tagModel.Name" />
			<input type="text" maxlength="@Tag.MaxCodeLength" name="code" class="codeColumn @(tagModel.IsCodeValid ? "" : "errorInput")" value="@tagModel.Code" />
			<button class="linkButton" value="Save" name="action" title="@Resources.SaveTag">@Resources.Save</button>
		}
		@using (this.Html.BeginForm("Delete", "Tags"))
		{
			<input type="hidden" name="tagid" value="@tagModel.Id" />
			<button class="linkButton" value="Delete" name="action" title="@Resources.DeleteTag">@Resources.Delete</button>
		}
		</div>
	}
</div>